package 面向对象;

import java.util.Random;

public class Game {
    private String name;
    private int blood;
    public  Game(){}
    public Game (String name , int blood){
        this.name=name;
        this.blood =blood;
    }
    public  String getName(){
        return name;
    }
    public void setName(String name){
        this.name=name;
    }
    public int getBlood(){
        return blood;
    }
    public void setBlood(int blood){
       this.blood=blood;
    }
    public void qwe(Game game){
        //随机生成一个1-20的伤害值
        Random q = new Random();
        int hurt = q.nextInt(20)+1;
        //剩余血量
        int qwe = game.getBlood() - hurt;
        //剩余血量为负数时，应将其置为0
        qwe=  qwe < 0 ? 0 : qwe;
        game.setBlood(qwe);
        //this
        System.out.println(this.getName()+"那勺子给了"+game.getName()+"一下，" +
                "造成了"+hurt+"点伤害，"+game.getName()+"剩余血量为"+qwe);
    }
}

